package com.hndzyu.yd.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.WindowManager;

import com.hndzyu.yd.R;


/**
 * Created by YJ on 2018/10/12.
 */
public class SexDialog extends Dialog {

    private SexListener mListener;

    public void setListener(SexListener listener) {
        mListener = listener;
    }

    public SexDialog(@NonNull Context context) {
        super(context, R.style.my_dialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (null != getWindow()){
            WindowManager.LayoutParams lp = getWindow().getAttributes();
            lp.dimAmount = 0.5f;
            getWindow().setAttributes(lp);
        }
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        setContentView(R.layout.dialog_sex);
        findViewById(R.id.tv_man).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mListener.chooseMan();
            }
        });
        findViewById(R.id.tv_woman).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mListener.chooseWoman();
            }
        });
        setCanceledOnTouchOutside(true);
    }

    @Override
    public void dismiss() {
        super.dismiss();
    }
    public interface SexListener{
        void chooseMan();
        void chooseWoman();
    }
}
